﻿using Albatross.SampleApp.Model;
using Albatross.WPF.Common.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace Albatross.SampleClient.ViewModels {
	[DataContract]
	public class ContactViewModel : WorkspaceViewModel {
		[DataMember]
		public int ContactID { get; private set; }
		public Contact Contact { get; private set; }
		public ContactViewModel(int id) {
			ContactID = id;
			Title = "Contact: Loading";
		}

		public override async void LoadAsync(WPF.Common.IViewService viewService) {
			Func<Contact> func = new Func<Contact>(() => ContactsService.Instance.GetContactByID(ContactID));
			Contact = await Task.Run<Contact>(func);
			Title = string.Format("Contact: {0} {1}", Contact.FirstName, Contact.LastName);
		}
	}
}
